package com.hwg.emp.web.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hwg.emp.common.exception.EmpException;
import com.hwg.emp.service.DeptService;
import com.hwg.emp.service.ServiceFactroy;

public class DeleteDeptsController extends HttpServlet {

	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		
		try {

			String[] id = req.getParameterValues("userId");

			String[] ids = req.getParameterValues("deptId");
			DeptService service = ServiceFactroy.getService(DeptService.class);
			service.deleteDeptByIds(id);
		} catch (EmpException e) {
			req.setAttribute("message", e.getMessage());
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
			req.setAttribute("message", "系统繁忙,请稍后再试!");
		}
		req.getRequestDispatcher("/selectDepts.do").forward(req, resp);
	}
	
}
